package com.sskj.xgja.api;


import com.sskj.base.data.User;
import com.sskj.xgja.login.data.LoginBean;
import com.sskj.xgja.market.bean.BannerNoticeBean;
import com.sskj.xgja.market.bean.MarketData;
import com.sskj.xgja.market.bean.Stock;
import com.sskj.xgja.message.data.MessageData;
import com.sskj.xgja.message.data.NewsDetail;
import com.sskj.xgja.message.data.NoticeDetail;
import com.sskj.xgja.mine.data.AppVersionBean;
import com.sskj.xgja.mine.data.AssetRecord;
import com.sskj.xgja.mine.data.BankBean;
import com.sskj.xgja.mine.data.MineImgBean;
import com.sskj.xgja.mine.data.RechargeBean;
import com.sskj.xgja.mine.data.ShopInfo;
import com.sskj.xgja.mine.data.WebViewBean;
import com.sskj.xgja.transaction.data.CoinDetail;
import com.sskj.xgja.transaction.data.HoldOrderBean;
import com.sskj.xgja.transaction.data.OrderBean;
import com.sskj.xgja.transaction.data.OrderHistoryBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface ApiService {

    @FormUrlEncoded
    @POST("/Home/Qbw/user_login")
    Observable<HttpResponse<LoginBean>> login(@Field("mobile") String mobile, @Field("opwd") String opwd);

    //买入卖出（做多做空）
    @FormUrlEncoded
    @POST("/Home/Order/add_order")
    Observable<HttpResponse<Object>> placeOrder(
            @Field("otype") String action,// 融资 1 融券 2
            @Field("buynum") String entrustCount,//手数
            @Field("shopname") String stockCode,//股票代码
            @Field("newprice") String price,//买入价
            @Field("leverage") String billType);//杠杆

    //发送短信验证码
    @GET("/Home/Qbw/send_sms")
    Observable<HttpResponse<String>> getCode(@Query("type") String type, @Query("mobile") String mobile);

    //获取用户协议
    @GET("/home/qbw/agree")
    Observable<HttpResponse<String>> getAgress(@Query("type") String id);

    //忘记密码
    @FormUrlEncoded
    @POST("/home/qbw/reset_opwd")
    Observable<HttpResponse<String>> resetPassword(@Field("mobile") String account,
                                                   @Field("code") String code,
                                                   @Field("opwd") String ps,
                                                   @Field("opwd1") String ps2);

    // 修改密码
    @FormUrlEncoded
    @POST("/home/qbw/xiugai_pwd")
    Observable<HttpResponse<String>> updatePwd(@Field("mobile") String account,
                                               @Field("code") String code,
                                               @Field("opwd") String ps,
                                               @Field("opwd1") String ps2);

    // 修改密码
    @FormUrlEncoded
    @POST("/home/qbw/reset_tpwd")
    Observable<HttpResponse<String>> updatePwdBuy(@Field("mobile") String account,
                                               @Field("code") String code,
                                               @Field("tpwd") String ps,
                                               @Field("tpwd1") String ps2);


    //注册
    @FormUrlEncoded
    @POST("/Home/Qbw/register")
    Observable<HttpResponse<Object>> register(@Field("username") String name,
                                              @Field("mobile") String mobile,
                                              @Field("code") String code,
                                              @Field("opwd") String opwd,
                                              @Field("opwd1") String opwd1,
                                              @Field("tjuser") String inviteCode);

    //版本更新
    @FormUrlEncoded
    @POST("/Home/Version/check_version")
    Observable<HttpResponse<AppVersionBean>> checkVersion(@Field("type") int type, @Field("version") String version);

    // 添加自选
    @FormUrlEncoded
    @POST("/home/Users/add_optional")
    Observable<HttpResponse<Object>> addOptional(@Field("code") String code);

    // 删除自选
    @FormUrlEncoded
    @POST("/home/Users/optional_del")
    Observable<HttpResponse<Object>> removeOptional(@Field("code") String code);

    //账户详情
    @GET("/home/Users/getuserinfo")
    Observable<HttpResponse<User>> accountDetail();

    // 实名拒绝原因
    @GET("/home/Users/backRemark")
    Observable<HttpResponse<String>> getReason();


    //行情列表
    @POST("/home/ajax/getpro")
    Observable<HttpResponse<List<MarketData>>> marketList();

    @FormUrlEncoded
    @POST("/home/ajax/getpro")
    Observable<HttpResponse<List<MarketData>>> marketDetail(@Field("code") String code);

    //自选列表
    @GET("/home/Users/optional_list")
    Observable<HttpResponse<List<MarketData>>> optionalList();

    //搜索列表
    @GET("/home/Users/search_all")
    Observable<HttpResponse<List<MarketData>>> searchMarketList(@Query("code") String code);

    //Banner图  公告列表
    @GET("/home/ajax/getBanner")
    Observable<HttpResponse<BannerNoticeBean>> getBanner();

    //初级认证
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<String>> verify1(@Field("action") String action,//openAccount
                                             @Field("account") String account,
                                             @Field("username") String username,
                                             @Field("idCardNo") String idCardNo,
                                             @Field("cardType") String cardType,
                                             @Field("cardNo") String bankNumber,
                                             @Field("province") String province,
                                             @Field("city") String city,
                                             @Field("bankCardOpenBank") String address
    );

    //上传账户身份证号
    @POST("/Home/Qbw/set_renzheng")
    Observable<HttpResponse<String>> verify2(@Body RequestBody multipartBody);


    //行情资讯
    @GET("http://newsapi.eastmoney.com/kuaixun/v2/api/yw?limit=20&encode=ywjh&source=app&sys=ios&version=7001008")
    Observable<String> getMessageList();

    //行情资讯
    @GET("http://newsapi.eastmoney.com/kuaixun/v2/api/yw?limit=20&encode=ywjh&source=app&sys=ios&version=7001008")
    Observable<String> getMessageListMore(@Query("min_id") String minID);


    //行情资讯
    @GET("home/api/NoticeList")
    Observable<HttpResponse<MessageData>> getNoticeList(@Query("nowpage") int page,
                                                        @Query("nownums") int pageSize);

    //行情资讯
    @GET("app/interface?app=app")
    Observable<HttpResponse<MessageData>> getAppNewsDetail(@Query("action") String action,//newsInfo
                                                           @Query("id") String id);

    //资讯详情
    @FormUrlEncoded
    @POST("home/api/Notice")
    Observable<HttpResponse<NoticeDetail>> getNoticeDetail(@Field("id") String id);


    //商品详情
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<List<CoinDetail>>> getCoinDetail(@Field("action") String action,//newsInfo
                                                             @Field("account") String account,
                                                             @Field("stockCode") String code);

    //挂单
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<OrderBean>> getGuaDanList(@Field("action") String action,//dealInfo
                                                      @Field("account") String account,
                                                      @Field("billStatus") String billStatus);

    //挂单
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<String>> cancelOrder(@Field("action") String action,//cancelBill
                                                 @Field("account") String account,
                                                 @Field("id") String id);

    //持仓
    @GET("/Home/Order/chicang")
    Observable<HttpResponse<List<HoldOrderBean>>> getHoldList();

    //平仓
    @FormUrlEncoded
    @POST("/Home/Order/pingcang")
    Observable<HttpResponse<Object>> closeOrder(@Field("order_id") String countId);

    //当日委托
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<OrderHistoryBean>> todayEntrust(@Field("action") String action,//dealInfo
                                                            @Field("account") String account,
                                                            @Field("toDay") String code,
                                                            @Field("page") int page,
                                                            @Field("pageSize") int pageSize);//toDay

    //当日成交
    @GET("/Home/Order/chengjiao")
    Observable<HttpResponse<List<OrderHistoryBean.OrderHistory>>> todayDeal(@Query("p") int page,
                                                                            @Query("pageSize") int pageSize);//toDay


    //历史委托
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<OrderHistoryBean>> historyEntrust(@Field("action") String action,//dealInfo
                                                              @Field("account") String account,
                                                              @Field("entrust1") String entrust1,
                                                              @Field("entrust2") String entrust2,
                                                              @Field("page") int page,
                                                              @Field("pageSize") int pageSize);

    //历史成交 billStatus:(1:已接收 2:待成交 3:已取消 4:已成交 5：已作废)
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<OrderHistoryBean>> historyDeal(@Field("action") String action,//dealInfo
                                                           @Field("account") String account,
                                                           @Field("entrust1") String dealDate1,
                                                           @Field("entrust2") String dealDate2,
                                                           @Field("billStatus") String billStatus,
                                                           @Field("page") int page,
                                                           @Field("pageSize") int pageSize);

    //出入金记录
    @FormUrlEncoded
    @POST("home/Pay/recordList")
    Observable<HttpResponse<AssetRecord>> getAssetRecord(@Field("type") String type,
                                                         @Field("starttime") String applyDate1,
                                                         @Field("endtime") String applyDate2,
                                                         @Field("p") int page,
                                                         @Field("size") int pageSize);

    @GET("/Home/Ajax/index")
    Observable<HttpResponse<List<Stock>>> stockData(@Query("code") String code,
                                                    @Query("goodsType") String goodsType);


    //上传图片
    @POST("/home/Qbw/upload_pic")
    Observable<HttpResponse<MineImgBean>> uploadImage(@Body RequestBody multipartBody);

    //资讯详情
    @GET("http://newsapi.eastmoney.com/kuaixun/v2/api/content?newstype=1&source=app&sys=android&version=7001008")
    Observable<NewsDetail> getNewsDetail(@Query("newsid") String id);

    //上传头像
    @FormUrlEncoded
    @POST("/home/Users/update_headimg")
    Observable<HttpResponse<String>> uploadHead(@Field("headimg") String headImgUrl);


    //获取支付通道
    @FormUrlEncoded
    @POST("home/Trade/goldEntry")
    Observable<HttpResponse<RechargeBean>> getPayWay(@Field("amount") String action);
    //获取支付通道
    @GET("home/Pay/payChannelList")
    Observable<HttpResponse<List<RechargeBean>>> getPayWayNew();

    //获取银行卡
    @GET("app/interface?app=app")
    Observable<HttpResponse<List<BankBean>>> getBank(@Query("action") String action,//payChannelList
                                                     @Query("account") String account
    );

    // 入金

    @FormUrlEncoded
    @POST("home/Pay/goldEntry")
    Observable<HttpResponse<WebViewBean>> xgRecharge(@Field("amount") String amount);
    // 入金

    @FormUrlEncoded
    @POST("home/Payfinsaas/goldEntry")
    Observable<HttpResponse<WebViewBean>> xgRechargeNew(@Field("amount") String amount,
                                                        @Field("paytype") String paytype);

    // 获取实名认证协议
    @GET("/home/qbw/agree")
    Observable<HttpResponse<String>> getVerifyData(@Query("type") String type);


    // 获取商家信息
    @GET("/Home/ajax/pingtai_info")
    Observable<HttpResponse<ShopInfo>> getShopInfo(@Query("key") String key);

    //获取第三方地址
    @FormUrlEncoded
    @POST("home/Trade/tradeCreate")
    Observable<HttpResponse<String>> xinghuoPay(@Field("amount") String amount,//xinghuoOrderPay
                                                @Field("outTradeNo") String outTradeNo,
                                                @Field("type") String type);

    //星火Pay
    @FormUrlEncoded
    @POST("home/Pay/goldYield")
    Observable<HttpResponse<Object>> cashOut(@Field("amount") String amount,
                                             @Field("tpwd") String tpwd);

    //获取系统信息
    @FormUrlEncoded
    @POST("home/Pay/getGoldYieldFee")
    Observable<HttpResponse<SystemInfo>> getSystemInfo(@Field("amount") String amount);


    //设置止盈止损
    @FormUrlEncoded
    @POST("app/interface?app=app")
    Observable<HttpResponse<String>> setProfit(@Field("action") String action,//countUpdate
                                               @Field("account") String account,
                                               @Field("id") String id,
                                               @Field("stopLossPrice") String loss,
                                               @Field("stopProfitPrice") String win);

}
